package cn.swh.guguanjia.mapper;

import cn.swh.guguanjia.entity.SysArea;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@org.apache.ibatis.annotations.Mapper
public interface SysAreaMapper extends Mapper<SysArea> {
    @SelectProvider(type = SysAreaProvider.class, method = "selectPage")
    List<SysArea> selectPage(Map<String, Object> map);


    @Update("UPDATE sys_area  " +
            "SET parent_ids = REPLACE ( parent_ids, #{oldParentIds}, #{parentIds} )  " +
            " WHERE " +
            " FIND_IN_SET( " +
            " #{parentId},parent_ids)")
    int updateByParentIds(@Param("parentIds") String parentIds,
                          @Param("oldParentIds") String oldParentIds,
                          @Param("parentId") long parentId);


    //批量插入
    @InsertProvider(type = SysAreaProvider.class, method = "insetBatch")
    int insetBatch(@Param("areas") List<SysArea> areas);


}